<template>
  <div id="AsnDetail">
    <div class="detail">
      <component
        :inputData="detailData"
        :is="currentComponent"
      ></component>
    </div>
  </div>

</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "AsnDetail",
  mixins: [baseMixin],
  data () {
    return {
      newFlag: false,
      selectData: {},
      detailData: {
        ordertype: "",
        sequence: "",
        statuscode: ""
      },
      detailNav: "1",
      componentConfig: [
        {
          name: "particulars",
          label: this.$t('bill.detail'),
          component: () => import('./page/particulars.vue')
        }
      ]
    }
  },
  computed: {
    currentComponent () {
      return this.componentConfig[this.detailNav - 1].component;
    }
  },
  methods: {
    async getData () {
      try {
        let res = await this.$api.get(`/queryholdallocationmatrix12/${this.selectData.ordertypedescription}/${this.selectData.statuscode}`);
        
          this.detailData = res.bean;
        
      } catch (e) {
        this.$message.error(e);
      }
    },
    setdata (data, id, close) {
      this.detailData.toloc = data.loc;
      close(false);
    }
  },
  mounted () {
    let newFlag = this.$store.state.newFlag;
    //判断是否事新建
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.detailData = data.detail;
      this.selectData = data.routeData;
      this.detailNav = data.detailNav;
      this.$store.commit("setNewFlag", data.newFlag)
    } else if (!newFlag) {
      this.selectData = this.$store.state.routeData;
      let statuscode = this.getOptions('queryInventoryholdcodeDropDown');
      let ordertypedescription = this.getOptions('querycodeLkup/ORDERTYPE');
      let code1 = "";
      let code2 = "";
      statuscode.forEach(item => {
        if (item.description == this.selectData.holddescription) {
          code2 = item.code;
        }
      });
      ordertypedescription.forEach(item => {
        if (item.description == this.selectData.ordertypedescription) {
          code1 = item.code;
        }
      });
      this.selectData.ordertypedescription = code1;
      this.selectData.statuscode = code2;
      this.getData();
    }
  },
  components: {
    "v-detail": detail,
  },
}
</script>

<style scoped>
</style>
